<?php
class DB {
	private $username = "sam";
	private $password = "erty";
	private $host = "localhost";
	private $dbname = "sclera";
	private $connection;
	
	public function connectDb() {
		$this->connection = mysql_connect(
				$this->host, 
				$this->username, 
				$this->password
				);
		
		if(!$this->connection){
			print 'Error connecting to database: ' . mysql_error();
			exit;
		}
		$db = mysql_select_db($this->dbname, $this->connection);
		
		return $this->connection;
	}
	
	public function closeDb($pconn = null){
		if($pconn != null){
			mysql_close($pconn);
		}else if(isset($this->connection)){
				mysql_close($this->connection);
			}else{
				return false;
			}
		
		return true;
	}
}
?>